package com.bjc.base.web;

import com.bjc.base.bean.ResultVO;
import com.bjc.base.core.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.bjc.base.service.IBookLoseService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.bjc.base.bean.request.BookLoseReqVO;
import com.bjc.base.bean.response.BookLoseVO;

/**
 * <p>
 * 绘本丢失上报 前端控制器
 * </p>
 *
 * @author 许自辉
 * @since 2018-06-10
 */
@RestController
@RequestMapping("api/book")
@Api(value = "bookLose-api", tags = { "绘本丢失上报相关接口" })
public class BookLoseController {

    @Autowired
    private IBookLoseService bookLoseService;

	@ApiOperation("分页查询绘本丢失上报")
	@GetMapping("bookLose/findPage")
	public ResultVO getBookLosePage(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize,
			BookLoseReqVO bookLoseReqVO) {
		PageHelper.startPage(pageNum, pageSize);
		List<BookLoseVO> bookLoseVOs = bookLoseService.getList(bookLoseReqVO);
		return ResultGenerator.getSuccess(new PageInfo<BookLoseVO>(bookLoseVOs));
	}
	
	@ApiOperation("分页查询绘本丢失上报")
	@GetMapping("bookLose/find")
	public ResultVO getBookLosee(BookLoseReqVO bookLoseReqVO) {
		BookLoseVO bookLoseVO = bookLoseService.get(bookLoseReqVO);
		return ResultGenerator.getSuccess(bookLoseVO);
	}

	@ApiOperation("添加绘本丢失上报")
	@PostMapping("bookLose/create")
	public ResultVO createBookLose(@RequestBody BookLoseReqVO bookLoseReqVOs) {
		int count = bookLoseService.insert(bookLoseReqVOs);
		return ResultGenerator.getInsertSuccess(count);
	}

	@ApiOperation("更新绘本丢失上报")
	@PutMapping("bookLose/update")
	public ResultVO updateBookLose(@RequestBody BookLoseReqVO bookLoseReqVOs) {
		int count = bookLoseService.update(bookLoseReqVOs);
		return ResultGenerator.getUpdateSuccess(count);
	}

	@ApiOperation("批量删除绘本丢失上报")
	@DeleteMapping("bookLose/deleteList")
	public ResultVO deleteBookLose(@ApiParam(value = "bookLose id集合") @RequestBody int[] ids) {
		int count = bookLoseService.deleteList(ids);
		return ResultGenerator.getDeleteSuccess(count);
	}

}
